package com.longge;

/**
 * @创建人 xinglongge
 * @创建时间 2021/10/19
 * @描述
 */
public class SumOfLeftLeaves {

    private int res = 0;

    public int sumOfLeftLeaves(TreeNode root) {
        dfs(root);
        return res;
    }

    private int dfs(TreeNode root) {
        if (root == null) return 0;
        res += dfs(root.left);
        res += dfs(root.right);
        return root.left == null ? 0 : root.left.val;
    }

}
